﻿using CocoaAni.Net.WebSockets.Server.ArgAdapters.Base;
using CocoaAni.Net.WebSockets.Server.Attributes;
using CocoaAni.Net.WebSockets.Server.DefineInfos;
using CocoaAni.Net.WebSockets.Server.Exceptions;

namespace CocoaAni.Net.WebSockets.Server.ArgAdapters;

public class BinaryArgAdapter : MessageArgAdapter<byte[], BinaryArgAttribute>
{
    public override byte[]? GetTargetParameter(MessageArgContext argContext)
    {
        if (argContext.ArgDefineInfo.Type != typeof(byte[]))
        {
            throw new WebSocketMessageArgException("defineInfo.Type 不兼容！",argContext.WebSocketContext);
        }
        return argContext.Message.Data;
    }
}